<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>父页面</title>
</head>
<body>
<H1>我是父页面</H1>
<iframe src="http://47.97.196.173:83/" title="remote sensing retrieval" id="myIframe" width="100%" height="800px" ></iframe>
<script>
    // 创建模拟数据
    const responseData = {
      eachCity: "null",
      eachCounty: "贵安新区",
      eachProvince: "贵州省",
      orgName: "测试JG企业0802",
      phone: "13148472001",
      informationUse: "测试使用",
      commitTime: "2024-05-28 17:20:50",
      auditTime: "2024-05-28 17:30:47",
      userName: "htyw_123",
      appData: [{
        productId: "13136307001",
        gid: "71",
        pos: "贵州省毕节市",
        acquisitionTime: "2023-04-17 03:22:43",
        satellite: "GF1"
      }],
      status: "02"
    };

    // 监听子页面请求数据的消息
    window.addEventListener('message', (event) => {
      if (event.data.type === 'requestTableData') {
        // 发送响应消息给子页面
        event.source.postMessage({
          type: 'responseTableData',
          responseData
        }, event.origin);
      }
    });

  //监听iframe onload 事件，然后post 到子页面数据
    window.addEventListener('load', function() {
    const iframe = document.getElementById('myIframe');


    // Wait until the iframe is loaded
    iframe.onload = function() {
      iframe.contentWindow.postMessage(responseData, '*'); // '*' can be replaced with the specific origin if needed
    };
  });
  </script>
</body>
</html>
